package com.cq.hd.order.api;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.order.api.dto.*;
import com.cq.hd.order.api.pft.PftOrderCallBackParam;
import com.cq.hd.order.api.pft.PftOrderTicketParam;
import com.cq.hd.order.api.vo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(value = "hd-o2o-order-service", contextId = "order-api")
public interface TbOrderApi {

    // 获取活动红包可用状态
    @GetMapping("/order/getRedAvailableStatus")
    Result<Boolean> getRedAvailableStatus(@RequestParam("activeId") Long activeId, @RequestParam("userId") Long userId);

    // 获取用户已下单该活动的数量
    @GetMapping("/order/getActiveOrderNum")
    Result<Integer> getActiveOrderNum(@RequestParam("activeId") Long activeId, @RequestParam("userId") Long userId);

    // 我的活动的订单管理的统计
    @GetMapping("/order/getOrderStatistics")
    Result<ActiveOrderStatisticsVo> getOrderStatistics(@RequestParam("businessId") Long businessId,
                                                       @RequestParam("userId") Long userId,
                                                       @RequestParam("activeId") Long activeId);

    // 创建订单
    @PostMapping("/order/createOrder")
    Result<CreateOrderVo> createOrder(@RequestBody CreateOrderDto createOrderDto);

    // 创建拼团订单
    @PostMapping("/order/createGroupBuyOrder")
    Result<CreateOrderVo> createGroupBuyOrder(@RequestBody CreateOrderDto createOrderDto);

    // 创建积分订单
    @PostMapping("/order/createPointsOrder")
    Result<CreateOrderVo> createPointsOrder(@RequestBody CreateOrderDto createOrderDto);

    // 立即支付，唤起第三方支付
    @PostMapping("/order/pay")
    Result<OrderPayVo> pay(@RequestBody OrderPayDto orderPayDto);

    // 取消支付
    @PostMapping("/order/cancelPay")
    Result<Boolean> cancelPay(@RequestBody CancelPayDto cancelPayDto);

    // 积分商城:我的奖品[核销商品]
    @PostMapping("/order/pageMyPrizeOrder")
    Result<Page<MyPrizeOrderPageVo>> pageMyPrizeOrder(@RequestBody MyPrizePageDto myPrizePageDto);

    // 订单列表（我购买的订单，我卖出的订单，我分销的订单）
    @GetMapping("/order/pageAppOrder")
    Result<Page<AppOrderPageVo>> pageAppOrder(@SpringQueryMap AppOrderPageDto appOrderPageDto);

    // 卖出订单详情(商家查看)
    @GetMapping("/order/appOrderDetail")
    Result<AppOrderDetailVo> appOrderDetail(@SpringQueryMap AppOrderDetailDto appOrderDetailDto);

    // 拼团详情
    @GetMapping("/order/appGroupBuyOrderDetail")
    Result<AppGroupBuyOrderDetailVo> appGroupBuyOrderDetail(@SpringQueryMap AppGroupBuyOrderDetailQueryDto appGroupBuyOrderDetailQueryDto);

    // 查看拼团成员
    @GetMapping("/order/groupMembers")
    Result<List<GroupBuyMemberVo>> groupMembers(@SpringQueryMap GroupMembersQueryDto groupMembersQueryDto);

    // 报名详情（报名订单）
    @GetMapping("/order/appOrderEnrollActiveDetail")
    Result<AppOrderEnrollActiveDetail> appOrderEnrollActiveDetail(@SpringQueryMap AppOrderEnrollActiveDetailDto appOrderEnrollActiveDetailDto);

    // 取消订单
    @PostMapping("/order/cancelOrder")
    Result<Boolean> cancelOrder(@RequestBody CancelOrderDto cancelOrderDto);

    // 确认参与
    @PostMapping("/order/confirmJoin")
    Result<Boolean> confirmJoin(@RequestBody ConfirmJoinDto confirmJoinDto);

    // 后台分页团购/报名订单列表
    @GetMapping("/order/pageOrder")
    Result<Page<AdminOrderPageVo>> pageAdminOrder(@SpringQueryMap AdminOrderPageDto adminOrderPageDto);

    // 积分订单列表
    @PostMapping("/order/pageAdminPointsOrder")
    Result<Page<AdminPointsOrderPageVo>> pageAdminPointsOrder(@RequestBody AdminPointsOrderPageDto adminPointsOrderPageDto);

    // 佣金订单列表
    @PostMapping("/order/pageAdminCommissionOrder")
    Result<Page<AdminCommissionOrderPageVo>> pageAdminCommissionOrder(@RequestBody AdminCommissionOrderPageDto adminCommissionOrderPageDto);

    // 积分订单列表: 导出
    @PostMapping("/order/listAdminPointsOrder")
    Result<List<AdminPointsOrderPageVo>> listAdminPointsOrder(@RequestBody AdminPointsOrderPageDto adminPointsOrderPageDto);

    // 佣金订单列表：导出
    @PostMapping("/order/listAdminCommissionOrder")
    Result<List<AdminCommissionOrderPageVo>> listAdminCommissionOrder(@RequestBody AdminCommissionOrderPageDto adminCommissionOrderPageDto);

    // 订单审核
    @PostMapping("/order/audit")
    Result<Void> businessOrderAudit(@RequestBody OrderAuditDto orderAuditDto);

    // 订单批量审核
    @PostMapping("/order/batchAudit")
    Result<String> businessOrderBatchAudit(@RequestBody OrderBatchAuditDto orderBatchAuditDto);

    // 废弃
    // 团购订单详情
    @GetMapping("/order/detailAdminGroupOrder")
    Result<AdminGroupOrderDetailVo> detailAdminGroupOrder(@RequestParam("orderId") Long orderId);

    // 废弃
    // 报名订单详情
    @GetMapping("/order/detailAdminEnrollOrder")
    Result<AdminEnrollOrderDetailVo> detailAdminEnrollOrder(@RequestParam("orderId") Long orderId);

    // 订单详情
    @GetMapping("/order/detailAdminOrder")
    Result<AdminOrderDetailVo> detailAdminOrder(@RequestParam("orderId") Long orderId);

    // 获取某种类型订单的每个订单状态的订单个数
    @GetMapping("/order/getOrderCount")
    Result<List<AdminOrderCountVo>> getOrderCount(@SpringQueryMap AdminOrderCountDto adminOrderCountDto);

    // 商户分页团购/报名订单列表
    @GetMapping("/order/pageMerchantOrder")
    Result<Page<MerchantOrderPageVo>> pageMerchantOrder(@SpringQueryMap MerchantOrderPageDto merchantOrderPageDto);

    // 商户订单导出
    @GetMapping("/order/exportMerchantOrder")
    Result<List<MerchantOrderExportVo>> exportMerchantOrder(@SpringQueryMap MerchantOrderExportDto merchantOrderExportDto);

    // 商户订单统计
    @GetMapping("/order/getMerchantOrderStatistics")
    Result<MerchantOrderStatisticsVo> getMerchantOrderStatistics(@SpringQueryMap MerchantOrderPageDto merchantOrderPageDto);

    // 商户团购/报名订单详情
    @GetMapping("/order/detailMerchantOrder")
    Result<MerchantOrderDetailVo> detailMerchantOrder(@RequestParam("orderItemId") Long orderItemId, @RequestParam("merchantId") Long merchantId);

    // 核销确认(根据核销码获取订单确认数据)
    @GetMapping("/order/getByVerifyCode")
    Result<MerchantVerifyConfirmVo> getByVerifyCode(@RequestParam("verifyCode") String verifyCode, @RequestParam("merchantId") Long merchantId);

    // 确认核销
    @PostMapping("/order/verify")
    Result<Boolean> verify(@RequestBody MerchantVerifyDto merchantVerifyDto);

    // 票付通核销
    @PostMapping("/order/pftVerify")
    Result<Boolean> pftVerify(@RequestBody PftOrderCallBackParam param);

    // 票付通出票通知
    @PostMapping("/order/pftTicket")
    Result<Boolean> pftTicket(@RequestBody PftOrderTicketParam param);

    // 票付通门票参数下单预判
    @PostMapping("/order/pftOrderPreCheck")
    Result<Boolean> pftOrderPreCheck(@RequestParam("pftSupplier") String pftSupplier, @RequestParam("pftProduct")String pftProduct, @RequestParam("pftTicket")String pftTicket);

    // 核销记录列表:签到码/积分订单
    @GetMapping("/order/pageVerifyRecord")
    Result<Page<MerchantVerifyRecordPageVo>> pageVerifyRecord(@SpringQueryMap MerchantVerifyRecordPageDto merchantVerifyRecordPageDto);

    // 管理后台核销记录: 分页
    @GetMapping("/order/pageAdminVerifyRecord")
    Result<Page<AdminVerifyRecordPageVo>> pageAdminVerifyRecord(@SpringQueryMap ActiveVerifyRecordQueryDto activeVerifyRecordQueryDto);

    // 管理后台核销记录
    @GetMapping("/order/listAdminVerifyRecord")
    Result<List<AdminVerifyRecordPageVo>> listAdminVerifyRecord(@SpringQueryMap ActiveVerifyRecordQueryDto activeVerifyRecordQueryDto);

    // 活动核销商户
    @GetMapping("/order/listVerifyMerchant")
    Result<List<ActiveVerifyMerchantVo>> listVerifyMerchant(@RequestParam("activeId") Long activeId);

    // 核销记录列表:商品
    @GetMapping("/order/pageVerifyGoods")
    Result<Page<MerchantVerifyGoodsPageVo>> pageVerifyGoods(@SpringQueryMap MerchantVerifyGoodsPageDto merchantVerifyGoodsPageDto);

    // 核销记录:商品核销记录明细
    @GetMapping("/order/pageVerifyGoodsDetail")
    Result<Page<MerchantVerifyGoodsDetailPageVo>> pageVerifyGoodsDetail(@SpringQueryMap MerchantVerifyGoodsDetailPageDto merchantVerifyGoodsDetailPageDto);

    // 根据条件查询订单数据
    @GetMapping("/order/listByDto")
    Result<List<OrderVo>> listByDto(@SpringQueryMap OrderDto orderDto);

    // 用户在指定商家下单的数量，用于判断是否是商家新用户，能否使用新用户红包
    @GetMapping("/order/userBusinessOrderCount")
    Result<Integer> userBusinessOrderCount(@RequestParam("userId") Long userId, @RequestParam("businessId") Long businessId);

    // 用户在指定活动下单的数量，用于判断是否限购
    @GetMapping("/order/userActiveOrderCount")
    Result<Integer> userActiveOrderCount(@RequestParam("userId") Long userId, @RequestParam("activeId") Long activeId);

    // 消费延时订单消息
    @PostMapping("/order/consumerOrderDelayMsg")
    Result<Boolean> consumerOrderDelayMsg(@RequestParam("orderNo") String orderNo);

    // 系统取消支付（倒计时到了调用）
    @PostMapping("/order/systemCancelPay")
    Result<Boolean> systemCancelPay(@RequestBody CancelPayDto cancelPayDto);

    // 查单（只要唤醒了第三方支付，关闭第三方支付页面之后，不管是成功还是失败，都要调用）
    @PostMapping("/order/queryOrderPay")
    Result<Boolean> queryOrderPay(@RequestBody OrderPayQueryDto orderPayQueryDto);

    // 去支付
    @PostMapping("/order/toPay")
    Result<Boolean> toPay(@RequestBody OrderPayQueryDto orderPayQueryDto);

    // 消费订单退款消息
    @PostMapping("/order/consumerOrderRefundMsg")
    Result<Boolean> consumerOrderRefundMsg(@RequestParam("orderRefundId") Long orderRefundId);

    // 消费订单核销消息
    @PostMapping("/order/consumerOrderVerifyMsg")
    Result<Boolean> consumerOrderVerifyMsg(@RequestParam("orderId") Long orderId);

    // 根据活动id查询下单用户信息
    @PostMapping("/order/listAvatarByDto")
    Result<List<OrderAvatarVo>> listAvatarByDto(@RequestBody OrderDto orderDto);

    // 扫描待支付订单
    @PostMapping("/order/scanWaitePayOrder")
    Result<Boolean> scanWaitePayOrder();

    // 扫描支付中订单
    @PostMapping("/order/scanPayingOrder")
    Result<Boolean> scanPayingOrder();

    // 扫描待核销、核销中、已核销和活动核销时间已结束订单
    @PostMapping("/order/scanEndVerifyOrder")
    Result<Boolean> scanEndVerifyOrder();

    // 扫描处理中的订单结算支付流水记录
    @PostMapping("/order/scanOrderSettleBill")
    Result<Boolean> scanOrderSettleBill();

    // 子单结算任务
    @PostMapping("/order/subOrderSettleTask")
    Result<Boolean> subOrderSettleTask();

    // 子订单结算积分【下单用户积分结算】停用
    @PostMapping("/order/subOrderSettlePointsTask")
    Result<Boolean> subOrderSettlePointsTask();

    // 下单用户积分结算
    @PostMapping("/order/settleUserPointsTask")
    Result<Boolean> settleUserPointsTask();

    // 经纪人积分结算
    @PostMapping("/order/settleAgentPointsTask")
    Result<Boolean> settleAgentPointsTask();

    // 扫描已核销的订单，更新商家与经纪人，商家与商户之间的统计信息
    @PostMapping("/order/scanVerifiedOrder")
    Result<Boolean> scanVerifiedOrder();

    @GetMapping("/order/listAdminOrder")
    Result<List<AdminOrderPageVo>> listAdminOrder(@SpringQueryMap AdminOrderPageDto adminOrderPageDto);

    // 返回最近10个订单用户头像返回
    @GetMapping("/order/getLastAvatar")
    Result<List<String>> getLastAvatar(@RequestParam("orderId") Integer count);

    // 生成商户本金手续费待转账记录 todo 商户本金手续费处理完之后需要删掉
    @PostMapping("/order/generateOrderSettleBillFeeTemp")
    Result<Boolean> generateOrderSettleBillFeeTemp();

    // 扫描处理中的订单结算手续费支付流水记录 todo 商户本金手续费处理完之后需要删掉
    @PostMapping("/order/scanOrderSettleBillFeeTemp")
    Result<Boolean> scanOrderSettleBillFeeTemp();

    // 根据提现单ID，获取关联订单列表
    @GetMapping("/order/listByWithdrawalId")
    Result<List<AdminOrderPageVo>> listByWithdrawalId(@RequestParam("withdrawalId") Long withdrawalId);

    // 分销排行榜
    @GetMapping("/order/agentRank")
    Result<ActiveAgentRankVo> agentRank(@RequestParam("activeId") Long activeId);

    // 分销排行分页
    @GetMapping("/order/pageAgentRank")
    Result<Page<AgentRankItemVo>> pageAgentRank(@SpringQueryMap ActiveRankQueryDto activeRankQueryDto);

    // 活动结束通知
    @PostMapping("/order/onActiveEnd")
    Result<Void> onActiveEnd(@RequestParam("activeId") Long activeId);

    // 未满员自动退款
    @PostMapping("/order/noFullAutoRefund")
    Result<Void> noFullAutoRefund(@RequestParam("activeId") Long activeId);

    // 活动结束触发计算阶梯价返现
    @PostMapping("/order/calculateStepPriceRefund")
    Result<Void> calculateStepPriceRefund(@RequestParam("activeId") Long activeId);

    // 订单预估佣金统计
    @GetMapping("/order/getOrderEstimateCommission")
    Result<OrderEstimateCommissionVo> getOrderEstimateCommission(@RequestParam("agentId") Long agentId);

    // 待成团订单列表（可直接参团）
    @GetMapping("/order/listPendingGroupBuyOrders")
    Result<List<PendingGroupOrderVo>> listPendingGroupBuyOrders(@RequestParam("activeId") Long activeId, @RequestParam("userId") Long userId);

    // 统计拼团活动订单数量
    @PostMapping("/order/statisticsGroupOrderNumByActiveIds")
    Result<List<GroupBuyOrderNumStatVo>> statisticsGroupOrderNumByActiveIds(@RequestBody List<Long> activeIds);

    // 拼团团组分页
    @PostMapping("/order/pageGroupBuyOrders")
    Result<Page<GroupBuyOrderPageVo>> pageGroupBuyOrders(@RequestBody GroupBuyOrderPageDto groupBuyOrderPageDto);

    // 0元开团
    @PostMapping("/order/createZeroGroupBuyOrder")
    Result<Long> createZeroGroupBuyOrder(@RequestBody CreateZeroGroupBuyOrderDto createZeroGroupBuyOrderDto);

    // 扫描到期的拼团订单
    @PostMapping("/order/scanExpiredGroupBuyOrders")
    Result<Void> scanExpiredGroupBuyOrders();

}
